﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="DemoExtNet.Validation.Default" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Remote Validation - Ext.NET Examples</title>
    <link href="../../../../resources/css/examples.css" rel="stylesheet" type="text/css" />
     <ext:ResourcePlaceHolder ID="ResourcePlaceHolder1" runat="server" />
      <script src="Validation.js" type="text/javascript"></script>
    <script type="text/javascript">
//        var myValidator = function(value) {

//        return value > 10 ? true : String.format('{0} is not valid',value);
//    }
        
    </script>
</head>
<body>
    <form id="Form1" runat="server">
   
    
    <ext:ResourceManager runat="server" Locale="vi" />       
    <ext:FormPanel runat="server" Layout="FormLayout"  Width="400" Title="Number Field" MonitorValid="true" LabelWidth="120">
        <Items>
            <ext:NumberField ID="txtNumberField1" runat="server" FieldLabel="Min-max value" MsgTarget="Side" MaxValue="100" MinValue="10">
            </ext:NumberField>        
            <ext:NumberField ID="txtNumberField2" runat="server" FieldLabel="AllowBlank" AllowBlank="false" MsgTarget="Side">
            </ext:NumberField>
            <ext:NumberField ID="NumberField3" runat="server" FieldLabel="AllowDecimals" AllowDecimals="true" DecimalSeparator="." MsgTarget="Side">
            </ext:NumberField>
            <ext:NumberField ID="NumberField4" runat="server" FieldLabel="AllowNegative" AllowNegative="true" MsgTarget="Side">
            </ext:NumberField>
            <ext:NumberField ID="NumberField5" runat="server" FieldLabel="Maxlength" MsgTarget="Side" MaxLength="4">
            </ext:NumberField> 
        </Items>
    </ext:FormPanel>
    <ext:FormPanel ID="FormPanel1" runat="server" Layout="FormLayout" Width="400" Title="Text Field"
        MonitorValid="true" LabelWidth="120">
        <Items>
            <ext:TextField ID="TextField3" runat="server" Regex="/^(19|20)[0-9]{2}$/" FieldLabel="Regex"
                MsgTarget="Side" />
            <ext:TextField ID="TextField4" runat="server" MaskRe="[a-z]" FieldLabel="MaskRe (ex:[123][a-z])"
                MsgTarget="Side" />
            <ext:TextField ID="TextField5" runat="server" AllowBlank="false" FieldLabel="AllowBlank"
                MsgTarget="Side" />
            <ext:TextField ID="TextField7" runat="server" Validator="TextField_Validator" FieldLabel="Validator"
                MsgTarget="Side" />
            <ext:TextField ID="TextField8" runat="server" Vtype="TextField_VType" FieldLabel="VType"
                MsgTarget="Side">
            </ext:TextField>
            <ext:TextField ID="TextField6" runat="server" MaxLength="10" FieldLabel="Maxlength"
                MsgTarget="Side">
            </ext:TextField>
        </Items>
    </ext:FormPanel>
        
       <ext:FormPanel ID="FormPanel2" runat="server" Layout="FormLayout" Width="400" Title="Datetime"
        MonitorValid="true" LabelWidth="120">
           <Items>
               <ext:DateField ID="DateField1" runat="server" DataIndex="LastChange" MsgTarget="Side"
                   AllowBlank="false" FieldLabel="Last change" Width="120" Format="d/M/yyyy" />
                  <ext:CompositeField runat="server" FieldLabel="From To Vtype=daterange">
                      <Items>
                          <ext:DateField ID="DateField2" runat="server" Vtype="daterange" FieldLabel="To" AnchorHorizontal="100%">
                              <CustomConfig>
                                  <ext:ConfigItem Name="endDateField" Value="#{DateField3}" Mode="Value" />
                              </CustomConfig>
                          </ext:DateField>
                          <ext:DateField ID="DateField3" runat="server" Vtype="daterange" FieldLabel="From"
                              AnchorHorizontal="100%">
                              <CustomConfig>
                                  <ext:ConfigItem Name="startDateField" Value="#{DateField2}" Mode="Value" />
                              </CustomConfig>
                          </ext:DateField>
                      </Items>
                  </ext:CompositeField>
           </Items>
        </ext:FormPanel>
    <div>
        1. vtype = email
        
        //
        1.IsNull
        2.IsNotNull
        3.IsString
        4.IsInt
        5.IsFloat
        6.IsDate
        7.IsTime
        8.IsEquals
        9.IsGreater
        10.IsEqualGreater
        11.IsSmaller
        12.IsEqualSmaller
        13.ChkMin
        14.ChkMax
        15.ChkMinMax
        16.ChkRegular
        17.ChkSpecialChar
        18.ChkUserName
        19.ChkPassword
        20.None
    </div>
    

    
    <ext:FormPanel runat="server" Title="Remote Validation Form" Padding="5" Frame="true"
        LabelWidth="250" MonitorValid="true" Width="500" DefaultAnchor="-20" Height="230">
        <Items>
            <ext:TextField runat="server" FieldLabel="No validation" />
            <ext:TextField runat="server" FieldLabel="Client only validation" AllowBlank="false" />
            <ext:TextField runat="server" FieldLabel="Server only validation" IsRemoteValidation="true">
                <RemoteValidation OnValidation="CheckField" />
            </ext:TextField>
            <ext:TextField runat="server" FieldLabel="Client and server validation" IsRemoteValidation="true"
                AllowBlank="false">
                <RemoteValidation OnValidation="CheckField" />
            </ext:TextField>
            <ext:TextField runat="server" FieldLabel="Client and server validation (web service)"
                IsRemoteValidation="true" AllowBlank="false">
                <RemoteValidation Url="ValidationService.asmx/CheckField" Json="true" />
            </ext:TextField>
            <ext:ComboBox runat="server" AllowBlank="false" Editable="false" FieldLabel="ComboBox"
                IsRemoteValidation="true">
                <RemoteValidation OnValidation="CheckCombo" ValidationEvent="select" EventOwner="Field">
                </RemoteValidation>
                <Items>
                    <ext:ListItem Text="Invalid" Value="1" />
                    <ext:ListItem Text="Valid" Value="2" />
                </Items>
            </ext:ComboBox>
        </Items>
        <Buttons>
            <ext:Button ID="Button1" runat="server" Text="Submit" FormBind="true" />
        </Buttons>
        <Listeners>
            <ClientValidation Handler="#{Button1}.setDisabled(!valid);" />
        </Listeners>
    </ext:FormPanel>
    <ext:NumberField 
            ID="NumberField1" 
            runat="server" 
            Number="5"
            Vtype="numberrange" 
            FieldLabel="From"
            LabelWidth="30" 
            EndNumberField="#{NumberField2}" 
            />
            
        <ext:NumberField 
            ID="NumberField2" 
            runat="server" 
            Vtype="numberrange" 
            FieldLabel="To"
            LabelWidth="30" 
            StartNumberField="#{NumberField1}" 
            />
            <ext:TextField ID="txtTest" runat="server" Vtype="customText" AllowBlank ="false" BlankText="Trường này không được trống"></ext:TextField>
           <ext:TextField runat="server" Vtype="email"></ext:TextField>
    <br />
    <ext:FormPanel ID="pnlRequireField" runat="server" Title="1. Require Field" Padding="5"
        Frame="true" LabelWidth="100" MonitorValid="true" Width="400" AutoHeight="true">
        <Items>
            <ext:TextField ID="txtRequireField1" FieldLabel="TextField" runat="server" Text=""
                AllowBlank="false" MsgTarget="Side" Width="260">
            </ext:TextField>
            <ext:NumberField ID="ChangeField" runat="server" MsgTarget="Side" AllowBlank="false"
                FieldLabel="Number Field" Width="260" />
            <ext:ComboBox ID="cboRequireField" runat="server" AllowBlank="false" FieldLabel="Require Field"
                MsgTarget="Side" Width="260">
                <Items>
                    <ext:ListItem Text="1" Value="1" />
                    <ext:ListItem Text="2" Value="2" />
                </Items>
            </ext:ComboBox>
            <ext:DateField ID="dfRequireField" runat="server" AllowBlank="false" FieldLabel="Date time"
                MsgTarget="Side" Width="260">
            </ext:DateField>
            <ext:TimeField ID="timeField" runat="server" AllowBlank="false" FieldLabel="Date Time"
                MsgTarget="Side" Width="260" />
            <ext:TextField ID="txtUrl" runat="server" Width="260" Vtype="url" FieldLabel="URL">
            </ext:TextField>
            <ext:TextField ID="txtIsGreater" runat="server" Vtype="IsEqualGreater" ValidationEvent="true" MaskRe="[0-9]"
                AllowBlank="false" FieldLabel="Is Greater" MsgTarget="Side" InvalidText="aa" />
            <ext:TextField ID="txtIsTring" runat="server" Vtype="IsString" FieldLabel="Is String" MsgTarget="Side" ></ext:TextField>    
        </Items>
        <Buttons>
            <ext:Button ID="Button2" runat="server" Text="Submit"  >
                <Listeners>
                    <Click Handler="if(#{pnlRequireField}.isValid()){alert('ok');}else{alert('false');}" />
                </Listeners>
            </ext:Button>
        </Buttons>
        <Listeners>
            <%--<ClientValidation Handler="#{Button2}.setDisabled(!valid);" />--%>
        </Listeners>
    </ext:FormPanel>
    <ext:Panel ID="pnlIsInt" runat="server" Title="IsInt" Width="400">
        <Items>
            <ext:DisplayField runat="server" Html=""></ext:DisplayField>
            <ext:DisplayField ID="DisplayField1" runat="server" Html="Number Field"></ext:DisplayField>
            <ext:NumberField runat="server" MaxLength="4"></ext:NumberField>
            <ext:DisplayField ID="DisplayField2" runat="server" Html="TextField su dung them thuoc tinh MaskRe='[0-9]'"></ext:DisplayField>
             <ext:TextField ID="TextField1" runat="server"  MaskRe="[0-9]"
                MsgTarget="Side" InvalidText="aa" />
        </Items>
    </ext:Panel>
    
     <ext:TextField ID="TextField2" 
                    runat="server"                     
                    Vtype="password"
                    FieldLabel="Confirm Password"
                    InputType="Password"
                    MsgTarget="Side"
                    Width="175">     
                    <%--<CustomConfig>
                        <ext:ConfigItem Name="initialPassField" Value="#{PasswordField}" Mode="Value" />
                    </CustomConfig>--%>                      
                </ext:TextField>   
                
                  
    </form>
    
</body>
</html>
